Utility.FileIO: set close-on-exec flag for all functions
authorJoey Hess <joeyh@joeyh.name>
Fri, 5 Sep 2025 17:36:50 +0000 (13:36 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 5 Sep 2025 17:36:50 +0000 (13:36 -0400)
commitc18581c356dbf7074488d0ad04b31c3bc9a8ecc3
treee30914313ac30cca16c6d42409e50eaacdca7bb2
parentfe6775619758e16f3e8cb77b4ee1d0775ae7795c
Utility.FileIO: set close-on-exec flag for all functions

Utility.FileIO.CloseOnExec is largely copied from
System.File.OsPath.Internal with the simple modification of
setting the flag.

Unfortunately, openTempFile does not set the flag when
opening the file, but afterwards, leaving it vulnerable to a race.
A lot of code, including posix and windows specific code,
would need to be copied from file-io in order to fix that.
Still, I consider this implementation a placeholder, it doesn't truely
fix all instances of the problem.

I hope that this will be addressed in file-io itself, see
https://github.com/haskell/file-io/issues/44

Utility.FileIO.CloseOnExec could form the basis of a
file-io-closeonexec library, depending on how things go with that
issue.

Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
COPYRIGHT
Utility/FileIO.hs
Utility/FileIO/CloseOnExec.hs [new file with mode: 0644]
git-annex.cabal